package com.aoip.telemetry.telemetry.entity.protocol;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.time.LocalDateTime;

/**
 * @author chenbai
 * @version 1.0
 * @date 2022/2/16 14:16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Builder
@TableName("protocol_base")
@ApiModel(description = "接收、解析协议基本信息表")
public class ProtocolBaseEntity {
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @ApiModelProperty("处理器规则主键")
    private String id;

    @TableField(value = "protocol_name")
    @ApiModelProperty("处理器名称，默认处理器类小写字母开头类名称")
    private String protocolName;

    @TableField(value = "protocol_desc")
    @ApiModelProperty("处理器说明")
    private String protocolDesc;

    @TableField(value = "protocol_code_format")
    @ApiModelProperty("报文编码格式")
    private String protocolCodeFormat;

    @TableField(value = "protocol_communicate")
    @ApiModelProperty("通信协议类型（tcp，udp）")
    private String protocolCommunicate;

    @TableField(value = "protocol_entry")
    @ApiModelProperty("解析协议入口类，入库方法统一为：entry，扫描包入口全限定名称")
    private String protocolEntry;

    @TableField(exist = false)
    @ApiModelProperty("协议使用端口(多个端口用英文逗号隔开)，数组格式，供界面展示用")
    private int[] protocolPort;

    @TableField(value = "protocol_ports")
    @ApiModelProperty("协议使用端口(多个端口用英文逗号隔开)")
    private String protocolPorts;

    @TableField(value = "protocol_file_id")
    @ApiModelProperty("文件id(针对处理器类型为jar时，上传jar的文件id)")
    private String protocolFileId;

    @TableField(exist = false)
    @ApiModelProperty("文件id(针对处理器类型为jar时，上传jar的文件路径)")
    private String protocolFilePath;

    @TableField(value = "is_has_call")
    @ApiModelProperty("是否含有召测（1是，0 否）")
    private String hasCall;

    @TableField(value = "st_code_index_range")
    @ApiModelProperty("测站编码所在报文的起始索引")
    private String stCodeIndexRange;

    @TableField(value = "is_has_heartbeat")
    @ApiModelProperty("是否含有心跳检测（1是，0 否）")
    private String hasHeartbeat;

    @TableField(value = "read_idle")
    @ApiModelProperty("读空闲（秒）")
    private int readIdle;

    @TableField(value = "write_idle")
    @ApiModelProperty("写空闲（秒）")
    private int writeIdle;

    @TableField(value = "msg_separation_mode")
    @ApiModelProperty("报文分隔方式(1：固定长度；2：回车换行符；3：特定字符；4：长度域)")
    private String msgSeparationMode;

    @TableField(value = "frame_length")
    @ApiModelProperty("报文帧固定长度字节")
    private int frameLength;

    @TableField(value = "max_frame_length")
    @ApiModelProperty("帧最大长度")
    private int maxFrameLength;

    @TableField(value = "frame_separator")
    @ApiModelProperty("帧分隔符")
    private String frameSeparator;

    @TableField(value = "length_field_offset")
    @ApiModelProperty("长度偏移量")
    private int lengthFieldOffset;

    @TableField(value = "length_field_length")
    @ApiModelProperty("长度占用字节")
    private int lengthFieldLength;

    @TableField(value = "length_adjustment")
    @ApiModelProperty("长度字节调整")
    private int lengthAdjustment;

    @TableField(value = "initial_bytes_to_strip")
    @ApiModelProperty("剥离字节数")
    private int initialBytesToStrip;

    @TableField(value = "content_after_length")
    @ApiModelProperty("正文后附加字节数")
    private int contentAfterLength;

    @ApiModelProperty(value = "是否有效（0：正常，1：无效）")
    @TableField("valid")
    private Integer valid;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    @TableField(value = "modify_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty("修改时间")
    private LocalDateTime modifyTime;

    @TableField(value = "del_flag", fill = FieldFill.INSERT)
    @ApiModelProperty("是否删除（0：正常，1：删除）")
    @TableLogic
    private Integer delFlag;

    @TableField(value = "bz")
    @ApiModelProperty("备注信息")
    private String bz;
}
